$('#notifikasi').click(function () {
	$("#dian-wrapper").css({right: "0px"});
	$("#maho, #notifikasi2").fadeIn();
	$("#notifikasi").fadeOut()
});
$('#notifikasi2').click(function () {
	$("#dian-wrapper").css({right: "-381px"});
	$("#maho, #notifikasi2").fadeOut();
	$("#notifikasi").fadeIn()
});
$('#maho').click(function () {
	$("#dian-wrapper").css({right: "-381px"});
	$("#maho, #notifikasi2").fadeOut();
	$("#notifikasi").fadeIn()
});
document.getElementById('notifikasi').onclick = function () {
	document.title = originalTitle;
	$('#show-jumlah').fadeOut()
};
document.getElementById('show-jumlah').onclick = function () {
	document.title = originalTitle;
	$('#show-jumlah').fadeOut();
	$("#dian-wrapper").css({right: "0px"});
	$("#maho").fadeIn()
};
var dian_config_defaults = {
	home_page: "http://rrtblog.blogspot.com/",
	max_result: 15,
	t_w: 50,
	t_h: 50,
	summary: 9999,
	new_tab_link: false,
	ct_id: "comments-container",
	new_dian: " Komentar Baru!",
	interval: 30000,
	alert: true,
}, _cookie = {
		set: function (g, f, j) {
			var i, h;
			if (j) {
				i = new Date();
				i.setTime(i.getTime() + (j * 24 * 60 * 60 * 1000));
				h = "; expires=" + i.toGMTString()
			} else {
				h = ""
			}
			document.cookie = g + "=" + f + h + "; path=/"
		},
		get: function (f) {
			var e = f + "=",
				h = document.cookie.split(";"),
				j;
			for (var g = 0; g < h.length; g++) {
				j = h[g];
				while (j.charAt(0) == " ") {
					j = j.substring(1, j.length)
				}
				if (j.indexOf(e) == 0) {
					return j.substring(e.length, j.length)
				}
			}
			return null
		},
		del: function (b) {
			this.set(b, "", -1)
		}
	}, aku_dian = (_cookie.get("aku_dian")) ? _cookie.get("aku_dian") : 0,
	doc_title = document.title;
for (var i in dian_config_defaults) {
	dian_config_defaults[i] = (typeof (dian_config[i]) == "undefined") ? dian_config_defaults[i] : dian_config[i]
}

function showRecentComments(json) {
	var entry = json.feed.entry,
		total = parseInt(json.feed.openSearch$totalResults.$t, 10),
		skeleton = "",
		oldCount = aku_dian,
		co = dian_config_defaults;
	var totalComments = total - oldCount > 50 ? '50+' : total - oldCount;
	if (oldCount < total) {
		if (dian_config.alert === true) {
			alert((total - oldCount) + dian_config.new_dian)
		} else {
			if (dian_config.alert === false) {
				document.title = "(" + (total - oldCount) + dian_config.new_dian + ") " + document.title
			} else {
				dian_config.alert((total - oldCount), dian_config.new_dian)
			}
		}
	}
	skeleton = '<ul class="dian-outer">';
	for (var i = 0; i < entry.length; i++) {
		for (var j = 0; j < entry[i].link.length; j++) {
			if (entry[i].link[j].rel == "alternate") {
				link = entry[i].link[j].href;
				break
			}
		}
		var dash = link.lastIndexOf("/") + 1,
			dot = link.lastIndexOf("."),
			title = link.split("-").join(" ").substring(dash, dot) + "&hellip;";
		author = entry[i].author[0], name = author.name.$t, avatar = author.gd$image.src.replace(/\/s[0-9]+(\-c|\/)/, "/s" + co.t_w + "$1").replace(/http\:\/\/www.google.com\/url\?source\=imglanding(.*?)q\=/i, "").replace(/\.(jpg|jpeg|png|bmp|gif)(.*?)$/i, ".$1"), profile = (author.uri) ? author.uri.$t : "#nope", u = entry[i].id.$t.replace(/^.*?blog\-([0-9]+).*?post\-([0-9]+)/, "http://www.blogger.com/delete-comment.g?blogID=$1&postID=$2"), r = entry[i]["thr$in-reply-to"].source.split("default/")[1], d = entry[i].id.$t.replace(/^.*?blog\-([0-9]+).*?post\-([0-9]+)/, "http://www.blogger.com/comment-iframe.g?blogID=$1&postID=" + r + "&parentID=$2"), date = entry[i].gd$extendedProperty[1].value, content = ("content" in entry[i]) ? entry[i].content.$t.replace(/<i rel="pre">(.*?)<\/i>/ig, "<pre class='prettyprint lang-scm'>$1</pre>").replace(/<i rel="code">(.*?)<\/i>/ig, "<code>$1</code>").replace(/<i rel="link">(.*?)<\/i>/ig, "<a class='allow' href='$1'>\[link\]</a>") : "", nt = (co.new_tab_link) ? ' target="_blank"' : "";
		content = (content.length > co.summary) ? content.substring(0, co.summary) + "&hellip;" : content;
		skeleton += "<li>";
		skeleton += '<div class="dian-header"><a href="' + profile + '" title="' + name + '"' + nt + '><img alt="Loading..." style="width:' + co.t_w + "px;height:" + co.t_h + 'px;" src="' + avatar + '"></a><span class="author"><a href="' + profile + '" rel="nofollow">' + name + '</a> comment <a href="' + link + '" title="' + title + '"' + nt + " rel=>" + title + "</a></div></span>";
		skeleton += '<div class="dian-content">';
		skeleton += '<span class="dian-text">' + content + "</span>";
		skeleton += '<div class="dian-footer">' + date + ' <a href="' + d + '" onclick="window.open(this.href,&#39;_cf&#39;,&#39;scrollbars=1,width=470,height=250,left=355,top=135&#39;);return false;" title="reply code here"></a> <a href="' + u + '"  title="delete comment here" target="_blank"></a></span> </span>';
		skeleton += "</div></li>"
	}
	skeleton += "</ul>";
	document.getElementById(co.ct_id).innerHTML = skeleton;
	_cookie.set("aku_dian", total, 7000);
	aku_dian = total
}(function () {
	var head = document.getElementsByTagName("head")[0],
		script = document.createElement("script"),
		co = dian_config_defaults;
	script.type = "text/javascript";
	script.id = "dian-feed-script";
	script.src = co.home_page + "/feeds/comments/default?alt=json-in-script&redirect=false&max-results=" + co.max_result + "&callback=showRecentComments";
	head.appendChild(script);
	setInterval(function () {
		var newScript = document.createElement("script");
		newScript.type = "text/javascript";
		newScript.id = "dian-feed-script";
		newScript.src = co.home_page + "/feeds/comments/default?alt=json-in-script&redirect=false&max-results=" + co.max_result + "&callback=showRecentComments";
		var oldScript = document.getElementById("dian-feed-script");
		oldScript.parentNode.removeChild(oldScript);
		head.appendChild(newScript)
	}, co.interval)
})();
var Script = function () {
	jQuery('#sidebar-wp .sub-menu > a').click(function () {
		var last = jQuery('.sub-menu.open', $('#sidebar-wp'));
		last.removeClass("open");
		jQuery('.arrow', last).removeClass("open");
		jQuery('.sub', last).slideUp(200);
		var sub = jQuery(this).next();
		if (sub.is(":visible")) {
			jQuery('.arrow', jQuery(this)).removeClass("open");
			jQuery(this).parent().removeClass("open");
			sub.slideUp(200)
		} else {
			jQuery('.arrow', jQuery(this)).addClass("open");
			jQuery(this).parent().addClass("open");
			sub.slideDown(200)
		}
		var o = ($(this).offset());
		diff = 200 - o.top;
		if (diff > 0) $("#sidebar-wp").scrollTo("-=" + Math.abs(diff), 500);
		else $("#sidebar-wp").scrollTo("+=" + Math.abs(diff), 500)
	})
}();
$(document.body).append('<div id="redirect"></div>');
$(window).on("beforeunload", function () {
	$('#redirect').fadeIn(1000).delay(6000).fadeOut(1000)
});
$(function () {
	$(window).scroll(function () {
		if ($(this).scrollTop() > 100) {
			$('#BounceToTop').slideDown(200)
		} else {
			$('#BounceToTop').slideUp(300)
		}
	});
	$('#BounceToTop').click(function () {
		$('body,html').animate({
			scrollTop: 0
		}, 800).animate({
			scrollTop: 25
		}, 200).animate({
			scrollTop: 0
		}, 150).animate({
			scrollTop: 10
		}, 100).animate({
			scrollTop: 0
		}, 50)
	})
});
$(document).ready(function () {
	$('.ThumbTooltip').hover(function () {
		var a = $(this).attr('title');
		$(this).data('tipText', a).removeAttr('title');
		$('<p class="thumb-tooltip"></p>').text(a).appendTo('body').fadeIn('slow')
	}, function () {
		$(this).attr('title', $(this).data('tipText'));
		$('.thumb-tooltip').remove()
	}).mousemove(function (e) {
		var a = e.pageX + 20;
		var b = e.pageY + 10;
		$('.thumb-tooltip').css({
			top: b,
			left: a
		})
	})
});